package com.example.demo.common;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2023-09-17
 * Time: 12:06
 */

import com.example.demo.model.Userinfo;
import org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * session 工具类
 */
public class SessionUtils {
    //得到当前对象
    public static Userinfo getUser(HttpServletRequest request){
        HttpSession session=request.getSession(false);
        if(session!=null && session.getAttribute(AppVariable.SESSION_USERINFO_KEY)!=null){
            //登录状态
            return (Userinfo) session.getAttribute(AppVariable.SESSION_USERINFO_KEY);

        }
        return null;

    }

}
